const types = [
  {
    code: 'normal',
    name: '普通订单'
  }, {
    code: 'surveying',
    name: '测量订单'
  }
]

const status = [
  {
    name: '待付款',
    code: 'unpaid'
  }, {
    name: '等待测量',
    code: 'survey_pending'
  }, {
    name: '已测量，待付尾款',
    code: 'survey_completed'
  }, {
    name: '已付尾款，定制生产',
    code: 'tail_payment'
  }, {
    name: '待安装',
    code: 'install_pending'
  }, {
    name: "已完成",
    code: 'completed'
  },{
    name: '已付款',
    code: 'paid'
  }
]

var filterMethod = function(arr, val) {
  let result = arr.filter((item) => {
    return item.code === val
  })

  return result[0].name
}

var typeFilter = function(val) {
  return filterMethod(types, val)
}
var stateFilter = function(val) {
  return filterMethod(status, val)
}

export {typeFilter, stateFilter}
